}
}
-static void
-try_pixmap (Display *xdisplay,
- int screen,
- int depth)
-{
- Pixmap pixmap = XCreatePixmap (xdisplay,
- RootWindow (xdisplay, screen),
- 1, 1, depth);
- XFreePixmap (xdisplay, pixmap);
-}
-
-gboolean
-_gdk_x11_have_render (GdkDisplay *display)
-{
- Display *xdisplay = GDK_DISPLAY_XDISPLAY (display);
- GdkDisplayX11 *x11display = GDK_DISPLAY_X11 (display);
-
- if (x11display->have_render == GDK_UNKNOWN)
- {
- int event_base, error_base;
- x11display->have_render =
- XRenderQueryExtension (xdisplay, &event_base, &error_base)
- ? GDK_YES : GDK_NO;
-
- if (x11display->have_render == GDK_YES)
- {
- /*
- * Sun advertises RENDER, but fails to support 32-bit pixmaps.
- * That is just no good. Therefore, we check all screens
- * for proper support.
- */
-
- int screen;
- for (screen = 0; screen < ScreenCount (xdisplay); screen++)
- {
- int count;
- int *depths = XListDepths (xdisplay, screen, &count);
- gboolean has_8 = FALSE, has_32 = FALSE;
-
- if (depths)
- {
- int i;
-
- for (i = 0; i < count; i++)
- {
- if (depths[i] == 8)
- has_8 = TRUE;
- else if (depths[i] == 32)
- has_32 = TRUE;
- }
- XFree (depths);
- }
-
- /* At this point, we might have a false positive;
- * buggy versions of Xinerama only report depths for
- * which there is an associated visual; so we actually
- * go ahead and try create pixmaps.
- */
- if (!(has_8 && has_32))
- {
- gdk_error_trap_push ();
- if (!has_8)
- try_pixmap (xdisplay, screen, 8);
- if (!has_32)
- try_pixmap (xdisplay, screen, 32);
- XSync (xdisplay, False);
- if (gdk_error_trap_pop () == 0)
- {
- has_8 = TRUE;
- has_32 = TRUE;
- }
- }
-
- if (!(has_8 && has_32))
- {
- g_warning ("The X server advertises that RENDER support is present,\n"
- "but fails to supply the necessary pixmap support. In\n"
- "other words, it is buggy.");
- x11display->have_render = GDK_NO;
- break;
- }
- }
- }
- }
-
- return x11display->have_render == GDK_YES;
-}
-
/*****************************************************
* X11 specific implementations of generic functions *
*****************************************************/